<?php
class Exts_Models_TagsContents extends Exts_Db_Table_Abstract
{
    protected $_name = 'con_tags_contents';
	protected $_primary = array( 'content_id', 'content_type', 'tag_id' );

    /**
     * Save tag relation with the content
     * @param string $type Content Type
     * @param int $id Content Id
     * @param int $tagId Tag Id
     */
	public function save( $type, $id, $tagId )
	{
        $row = $this->createRow();
        $row->content_type = $type;
        $row->content_id = $id;
        $row->tag_id = $tagId ;
        return $row->save();

	}

    /**
     * Delete all relation tags as type = $type and content_id = $id
     * @param string $type Content Type
     * @param int $id Content Id
     */
    public function removeTags( $type, $id )
    {
        return $this->delete( "content_type='{$type}' AND content_id='{$id}'" );
    }

}



